import 'dart:convert';
import 'dart:core';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';
import 'package:intl/intl.dart';

extension Encryption on String {
  String toMd5() {
    var content = new Utf8Encoder().convert(this);
    var digest = md5.convert(content);
    return hex.encode(digest.bytes);
  }
}

extension Format on DateTime {
  String format() {
    if (this == null) return null;
    var formater = new DateFormat('yyyy-MM-dd');
    return formater.format(this);
  }
}
